package cvo.pro4.chess.client.pocDragDrop;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;

import cvo.pro4.chess.client.entities.Piece;

public class Basic2Widget extends Composite {

	private static Basic2WidgetgetUiBinder uiBinder = GWT
			.create(Basic2WidgetgetUiBinder.class);

	interface Basic2WidgetgetUiBinder extends UiBinder<Widget, Basic2Widget> {
	}

	public Basic2Widget() {
		initWidget(uiBinder.createAndBindUi(this));
	}

	//elk field van op de xml file moet je hier ook @UiField toewijzen. Dit is
	//de link tussen uw java doc en uw xml file.
	@UiField protected Label title;
	@UiField protected TextBox textbox;
	@UiField protected Button button;
	@UiField protected Label result;

	public Basic2Widget(String buttontext, String title) {
		initWidget(uiBinder.createAndBindUi(this));
		this.setButtontxt(buttontext);
		this.setTitle(title);
		//this.button.addClickHandler(new TestHandler());
	}
	
	//setter voor de tekst op de button
	public void setButtontxt(String text) {
		this.button.setText(text);
	}
	
	//de buttontekst ophalen
	public String getButtontxt() {
		return this.button.getText();
	}
	
	//setter voor de titel
	public void setTitle(String titletext){
		this.title.setText(titletext);
	}
	
	//getter voor de titel
	public String getTitle(){
		return this.title.getText();
	}
	
	//setter voor het resultaat
	public void setResult(String text){
		this.result.setText(text);
	}
	
	//getter voor het resultaat
	public String getResult(){
		return this.result.getText();
	}
	
	@UiHandler("button")
	void onClick(ClickEvent e) {
		this.setResult(textbox.getText());
	}	
}
